
package cn.webrx;

import java.time.format.DateTimeFormatter;
import java.util.Random;
import java.util.Scanner;

public class GuessNumGame {
    public static void main(String[] args) {
        //猜数游戏
        Scanner sc = new Scanner(System.in);
        //出题
        int num = new Random().nextInt(1, 101);
        int s = 0;

        while (true) {
            ++s;
            System.out.print("请输入数字：");
            int t = sc.nextInt();
            if (t > num) {
                System.out.println("太大了。%n");
            } else if (t < num) {
                System.out.println("太小了。%n");
            } else {
                System.out.printf("恭喜你，猜对了，你的游戏得 %d 分。", (100 - ((s - 1) * 10)));
                break;
            }
            if(s>=11){
                break;
            }
        }
    }
}
